#!/usr/bin/bash

# 示例(终端处在Home目录下)：pwd
# > ~$ pwd
# /home/zinface

# 示例：tree /home/zinface/Desktop/youwant/youwant.shell
# /home/zinface/Desktop/youwant/youwant.shell
# └── template.sh

############################# 基本本体信息 #############################

# 脚本内环境变量，如当前脚本完整名称
# template.sh
BASE_NAME="$(basename $0)"  # 用于区分,实际相同
FULL_NAME="$(basename $0)"  # 用于区分,实际相同

# 基本相对目录信息: 
# 当执行: 
#   ./Desktop/youwant/youwant.shell/template.sh
# 输出:
#   Desktop/youwant/youwant.shell
BASE_DIR_PATH=`dirname $0`

# 基本绝对目录信息: 
# 当执行: 
#   ./Desktop/youwant/youwant.shell/template.sh
# 输出:
#   /home/zinface/Desktop/youwant/youwant.shell
FULL_DIR_PATH=`cd $(dirname $0) && pwd`

# 其它组合信息(程序/脚本本体路径)：
BASE_APP_PATH="$BASE_DIR_PATH/$BASE_NAME"
FULL_APP_PATH="$FULL_DIR_PATH/$FULL_NAME"

# 当执行 
#   ./Desktop/youwant/youwant.shell/template.sh
# 内容：
#   echo $BASE_APP_PATH
#   echo $FULL_APP_PATH
# 输出：
#   ./Desktop/youwant/youwant.shell/template.sh                  # 相对路径
#   /home/zinface/Desktop/youwant/youwant.shell/template.sh      # 绝对路径


############################# 可自定义部分 #############################

echo $BASE_NAME
echo $FULL_NAME

echo $BASE_DIR_PATH
echo $FULL_DIR_PATH

echo $FULL_APP_PATH
echo $BASE_APP_PATH